package mint.modules.symbol;

import java.util.Formatter;

import mint.modules.generator.ClassDeclarationNode;

public class ClassSymbol extends Symbol {
	private SymbolModifier modifier;
	private String modifierText;
	private String superClass;
	private ClassDeclarationNode node;

	public ClassSymbol(ClassDeclarationNode classNode) {
		super(classNode.getName());
		
		node = classNode;		
		superClass = classNode.getSuperName();
		
		modifierText = classNode.getModifier();
		
		if (modifierText.equals("public"))
		{
			modifier = SymbolModifier.publicModifier;
		}
		else if (modifierText.equals("private"))
		{
			modifier = SymbolModifier.privateModifier;
		}
		else if (modifierText.equals("protected"))
		{
			modifier = SymbolModifier.protectedModifier;
		}
		else
			modifier = SymbolModifier.publicModifier;
		
	}
	
	public String getSuperClass()
	{
		return superClass;
	}
	
	public SymbolModifier getModifier()
	{
		return modifier;
	}
	
	public ClassDeclarationNode getClassNode()
	{
		return node;
	}

	@Override
	public SymbolType getSymbolType() {
		return SymbolType.Class;
	}

	@Override
	public void print(Formatter output, int tabSize) {
		for (int i = 1; i <= tabSize; i++)
			output.format("\t");
		
		if (superClass != null)
			output.format("%s class %s : %s\n", modifierText, getName(), superClass);
		else
			output.format("%s class %s\n", modifierText, getName());

	}
	
	public static final ClassSymbol stringSymbol = new ClassSymbol(ClassDeclarationNode.stringClass);

}
